package com.example.hans.viewpagetest;

import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ViewPager viewPager;
    private List<View> views;
    private MyPageAdapter myPageAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        viewPager = (ViewPager) findViewById(R.id.viewpager);
        views = new ArrayList<>();

        LayoutInflater inflater = LayoutInflater.from(getApplicationContext());

        View view1 = inflater.inflate(R.layout.tab1,null);
        View view2 = inflater.inflate(R.layout.tab2,null);
        View view3 = inflater.inflate(R.layout.tab3,null);

        views.add(view1);
        views.add(view2);
        views.add(view3);

        myPageAdapter = new MyPageAdapter(views);
        viewPager.setAdapter(myPageAdapter);

    }
}
